package com.nightsoul.cxf;

import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.core.Response;

import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;

public class TestInterceptor extends AbstractPhaseInterceptor<Message> {
	
	public TestInterceptor() {
		super(Phase.PRE_INVOKE);
	}

	@Override
	public void handleMessage(Message message) throws Fault {
		List<String> list = new ArrayList<>();
		list.add("zhaangsan");
		list.add("lisi");
		Response response = Response.status(200).entity(System.currentTimeMillis()).build();
		message.getExchange().put(Response.class, response);
		/*Message outMessage = message.getExchange().getBinding().createMessage();
		List<Response> list = new ArrayList<>();
		list.add(response);
		outMessage.setContent(List.class, list);
		message.getExchange().setOutMessage(message);
		System.out.println("test interceptor");*/

	}
	
}
